home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Freeware / Programare / highlight / highlight-W32GUI-2.2-10b-Setup.exe / {app} / src / ansigenerator.cpp next >
C/C++ Source or Header  |  2004-07-09  |  3KB  |  97 lines

  1. /***************************************************************************
  2.                     ansigenerator.cpp  -  description
  3.                              -------------------
  4.     begin                : Jul 5 2004
  5.     copyright            : (C) 2004 by Andr∩┐╜Simon
  6.     email                : andre.simon1@gmx.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This program is free software; you can redistribute it and/or modify  *
  12.  *   it under the terms of the GNU General Public License as published by  *
  13.  *   the Free Software Foundation; either version 2 of the License, or     *
  14.  *   (at your option) any later version.                                   *
  15.  *                                                                         *
  16.  ***************************************************************************/
  17.  
  18. #include "ansigenerator.h"
  19.  
  20. using namespace std;
  21.  
  22. namespace highlight {
  23.  
  24.  
  25. string  AnsiGenerator::getOpenTag(const string&font, 
  26.                                   const string&fgCol, const string&bgCol)
  27. {
  28.   ostringstream s;
  29.   s  << "\033["<<font;
  30.   if (!fgCol.empty())
  31.      s<<";"<<fgCol;  
  32.   if (!bgCol.empty())
  33.      s<<";"<<bgCol;
  34.   s << "m";
  35.   return  s.str();
  36. }
  37.  
  38.  
  39. AnsiGenerator::AnsiGenerator(const string &colourTheme)
  40.     : CodeGenerator(colourTheme)
  41. {
  42.   styleTagOpen.push_back("");  
  43.   styleTagOpen.push_back(getOpenTag("00", "31", "")); //str
  44.   styleTagOpen.push_back(getOpenTag("00", "34", ""));//number
  45.   styleTagOpen.push_back(getOpenTag("00", "33", ""));//sl comment
  46.   styleTagOpen.push_back(getOpenTag("00", "34", ""));//ml comment
  47.   styleTagOpen.push_back(getOpenTag("00", "35", ""));//escapeChar
  48.   styleTagOpen.push_back(getOpenTag("00", "36", ""));//directive
  49.   styleTagOpen.push_back(getOpenTag("01", "35", ""));//directive string
  50.   styleTagOpen.push_back(getOpenTag("00", "30", ""));//linenum
  51.   styleTagOpen.push_back(getOpenTag("01", "31", ""));//symbol
  52.  
  53.   styleTagClose.push_back("");  
  54.   for (int i=1;i<NUMBER_BUILTIN_STYLES; i++){
  55.     styleTagClose.push_back("\033[m");
  56.   }    
  57.   newLineTag = "\n";
  58.   spacer = " ";
  59. }
  60.  
  61. AnsiGenerator::AnsiGenerator()
  62. {}
  63. AnsiGenerator::~AnsiGenerator()
  64. {}
  65.  
  66. string AnsiGenerator::getHeader(const string & title)
  67. {
  68.   return string();
  69. }
  70.  
  71. void AnsiGenerator::printBody()
  72.   processRootState();
  73. }
  74.  
  75. string AnsiGenerator::getFooter()
  76. {  
  77.  return string();
  78. }
  79.  
  80. string AnsiGenerator::maskCharacter(unsigned char c)
  81. {  
  82.   string m;
  83.   m+=c;
  84.   return m;  
  85. }
  86.  
  87. string AnsiGenerator::getMatchingOpenTag(unsigned int styleID){
  88.  return (styleID)?getOpenTag("00", "32", ""):getOpenTag("01", "34", "");
  89. }
  90.  
  91. string AnsiGenerator::getMatchingCloseTag(unsigned int styleID){
  92.   return "\033[m";
  93. }
  94.  
  95. }
  96.